<?php
namespace app\crm\controller;
use think\Loader;

class Goodsbrand extends CrmController
{
    /**
     * 商品品牌列表界面
     * @return [type] [description]
     */
    public function goodsBrandList()
    {
		//分配增删改的权限
		$menuname = "Goods Brand";
		$p_menuname = $_SESSION['menu'][$menuname]; //父菜单
		$priv = $_SESSION["user_priv"][$p_menuname][$menuname];	
		$this->assign("username",$_SESSION['user_info']['username']);
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('goodsBrandList');
    }

	/**
     * 商品品牌添加界面
     */
    public function addBrand()
    {
        // 模板输出
        return $this->fetch('addBrand');
    }
	
	/**
     * 调用model的品牌添加方法
     */
    public function insertBrand()
    {
        //print_r($_REQUEST);die;
        Loader::model('Goodsbrand')->insertBrand($_REQUEST);
    }
	
	/**
     * 更新品牌的界面
     */
    public function editBrand()
    {
        $id = $_GET["id"];
        $arrData = Loader::model('Goodsbrand')->getBrandArr($id);
        $this->assign("arrData",$arrData);
        // 模板输出
        return $this->fetch('editBrand');
    }
	
	/**
     * 调用model的品牌更新方法
     */
    public function updateBrand()
    {
        $id = $_GET["id"];
        $data = array(
            'brand_name' => $_REQUEST['brand_name'],
            'brand_enabled' => $_REQUEST['brand_enabled'],
            'brand_order' => $_REQUEST['brand_order'],
            'brand_description' => $_REQUEST['brand_description']
        );
        Loader::model('Goodsbrand')->updateBrand($id,$data);
    }


    /**
     * 删除商品品牌
     * @return [type] [description]
     */
    public function delBrand()
    {
        $id = $_REQUEST["id"];
        Loader::model('Goodsbrand')->delBrand($id);
    }
	
	/**
     * 获取品牌列表
     */
    public function goodsBrandDataList(){
        $page = $_REQUEST["page"];
        $limit = $_REQUEST["limit"];
        $arrData = Loader::model('Goodsbrand')->getBrandData($page,$limit);
        echo json_encode($arrData);
    }





}